package vns.server;

import javax.jdo.PersistenceManager;

import vns.client.service.ObjectTypeIntegerService;
import vns.server.domain.ObjectTypeInteger;
import vns.shared.ObjectTypeIntegerDTO;


import com.google.appengine.api.datastore.Key;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class ObjectTypeIntegerServiceImpl extends RemoteServiceServlet 
		implements ObjectTypeIntegerService{

	@Override
	public ObjectTypeIntegerDTO Create(ObjectTypeIntegerDTO opIntegerDTO) {
		PersistenceManager pm=PMF.get().getPersistenceManager();
		ObjectTypeInteger action=null;
		try{
			action=new ObjectTypeInteger(opIntegerDTO);
			pm.makePersistent(action);
		}finally{
			pm.close();
		}
		return action.toDTO();
	}

	@Override
	public ObjectTypeIntegerDTO load(Key id) {
		PersistenceManager pm=PMF.get().getPersistenceManager();
		ObjectTypeIntegerDTO actionDTO=null;
		try{
			ObjectTypeInteger action = pm.getObjectById(ObjectTypeInteger.class,id);	
			actionDTO=action.toDTO();
		}finally{
			pm.close();
		}
		return actionDTO;
	}

	@Override
	public ObjectTypeIntegerDTO Update(ObjectTypeIntegerDTO opIntegerDTO) {
		PersistenceManager pm=PMF.get().getPersistenceManager();
		ObjectTypeInteger action=null;
		try{
			action=pm.getObjectById(ObjectTypeInteger.class,opIntegerDTO.getId());
			action.updatefromDTO(opIntegerDTO);
		}finally{
			pm.close();
		}
		
		return action.toDTO();
	}

	@Override
	public boolean remove(Key id) {
		PersistenceManager pm=PMF.get().getPersistenceManager();
		try{
			ObjectTypeInteger action= pm.getObjectById(ObjectTypeInteger.class,id);
			if(action!=null){
				pm.deletePersistent(pm.getObjectById(ObjectTypeInteger.class,id));
			}
		}finally{
			pm.close();
		}
		return true;
	}
}
